package com.baosu.controller.front;

import com.baosu.domain.ArticleDto;
import com.baosu.domain.Result;
import com.baosu.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/front/article")
@Api(tags = "文章接口-前台")
public class ArticleFrontController {

    @Autowired
    private ArticleService articleService;

    @GetMapping("/{id}")
    @ApiOperation(value = "查询文章详情,阅读量+1")
    public Result selectById(@PathVariable("id") Long id){
        articleService.updateCount(id);
        return articleService.selectById(id);
    }

    @GetMapping
    @ApiOperation(value = "分页列表,模糊搜索")
    public Result list(String query, int pagenum, int pagesize){
        return articleService.pageTagList(query,pagenum,pagesize);
    }

    @GetMapping("/hotArticleList")
    @ApiOperation(value = "热门文章top7")
    public Result hotArticleList(){
        return articleService.hotArticleList();
    }


}
